import type { PageParam, PageResult } from '@vben/request';
import type { Dayjs } from 'dayjs';

import { requestClient } from '#/api/request';

export namespace BookingOrderEventApi {
  /** 预约订单事件信息 */
  export interface BookingOrderEvent {
    id: number; // 事件ID
    bookingOrderId?: number; // 预约订单ID
    orderDetailId: number; // 订单明细ID
    resourceRequirementId: number; // 资源需求ID
    eventType?: string; // 事件类型
    eventStatus?: string; // 事件状态
    eventTime?: string | Dayjs; // 事件时间
    eventData: string; // 事件数据
    eventResult: string; // 事件结果
    errorMessage: string; // 错误信息
    triggerType?: string; // 触发类型
    triggerUserId: number; // 触发用户ID
    triggerSource: string; // 触发来源
    processorId: number; // 处理人ID
    processTime: string | Dayjs; // 处理时间
    processNotes: string; // 处理备注
  }
}

/** 查询预约订单事件分页 */
export function getBookingOrderEventPage(params: PageParam) {
  return requestClient.get<PageResult<BookingOrderEventApi.BookingOrderEvent>>('/spa/booking-order-event/page', { params });
}

/** 查询预约订单事件详情 */
export function getBookingOrderEvent(id: number) {
  return requestClient.get<BookingOrderEventApi.BookingOrderEvent>(`/spa/booking-order-event/get?id=${id}`);
}

/** 新增预约订单事件 */
export function createBookingOrderEvent(data: BookingOrderEventApi.BookingOrderEvent) {
  return requestClient.post('/spa/booking-order-event/create', data);
}

/** 修改预约订单事件 */
export function updateBookingOrderEvent(data: BookingOrderEventApi.BookingOrderEvent) {
  return requestClient.put('/spa/booking-order-event/update', data);
}

/** 删除预约订单事件 */
export function deleteBookingOrderEvent(id: number) {
  return requestClient.delete(`/spa/booking-order-event/delete?id=${id}`);
}


/** 导出预约订单事件 */
export function exportBookingOrderEvent(params: any) {
  return requestClient.download('/spa/booking-order-event/export-excel', { params });
}

